/*!
 * 列表视图控件.
 * ecp.qzz.ui.listview.js
 * 创建：QZZ
 * 日期：2014-03-01
 */
define(["qzz.frame","qzz.list","qzz.icheckbox"], function() {
	
	var qzz = window.qzz;
	qzz.space("ui");
	/**
	 * 视图控件.
	 */
	qzz.ui.listview = qzz.Class(qzz.ui.frame, {
		/**
		 * 创建.
		 */
		_create:function(){
		    this.base();
		    this.className = "ListView";
		    this.logInfo("listView.create");
		    //创建列表对象
		    this.list = new qzz.list();
		    //初始化
		    var data = this.getOption().data;
		    if(this.isNotEmpty(data)) {
		    	this.list.setItemList(data);
	    	}
		    data = null;
		    //显示位置
		    this.selectIndex = -1;
		    this.rowIndex = 0;
		    //显示行数
		    this.showCount = this._getNumberValue(this.getOption().showCount, 6);
		    this.selBackgroup = false;
		    //行高
		    if(this.getOption().fontSize !== "" && this.getOption().fontSize != null) {
		    	this._rowHeight = parseInt(this.getOption().fontSize, 10) * 1.9;
		    } else {
		        this._rowHeight = 23;
		    }
		    this._rowHeight = this._getNumberValue(this.getOption().rowHeight, this._rowHeight);
		    //高度
		    this._scrollFireEvent = this.getBooleanValue(this.getOption().scrollFireEvent, true);
		    this.getOption().height = this._rowHeight * this.showCount;
		    this.topIndex = 0;
		    this.getOption().width = this._getNumberValue(this.getOption().width, 150);
		    this.rendered = false;
		    this.autoHeight = false;
		    this.getOption().multiSelect = this.getBooleanValue(this.getOption().multiSelect, false);
		    this.getOption().selectAll = this.getBooleanValue(this.getOption().selectAll, false);
	    	this.getOption().idkey = this.getOption().idkey || "id";
	    	this.getOption().capkey = this.getOption().capkey || "text";
	    	this.list.idColName = this.getOption().idkey;
	    	this.list.textColName = this.getOption().capkey;
	    },
	    /**
	     * 渲染.
	     */
	    _render:function() {
	    	this.base();
	    	
	    	this.logInfo("listView.render");
	    	this.listTab = this.createElement("table");
	    	//样式及结构
	    	this.setStyle(this.listTab, "component_ui_listview_list_table");
	    	this.listTab.style.width = "100%";
	    	this.listTab._this = this;
	    	this.listDiv.appendChild(this.listTab);
	    	

	    	
	    	
	    		    	
	    	this.refresh();
	    	this.rendered = true;
	    },
	    refreash:function(text) {
	    	this.refresh(text);
	    },
	    setHeight:function(height) {
	    	var ch = height;	    	
    		this.base(ch);
    		this.thisWindow.style.height = ch + "px";
	    },
	    /**
	     * 刷新列表.
	     */
	    refresh:function(text) {
	    	if(!this._update) return false;
	    	var sWidth = "100%";//this.getTextWidth(this.list.getMaxText(), "12px") + 10;;
	    	if(this.getOption().viewType !=="image") {
	    		fs = "12px";
	    		if(this.getOption().fontSize != null) {
	    			fs = this.getOption().fontSize + "px";
	    		}
	    		sWidth = this.getTextWidth(this.list.getMaxText(), fs) + 10;
	    	}
	    	if(this.getOption().multiSelect) {
	    		sWidth += 23
	    	}	    	
	    	//如果配置了selectAll为true则增加“全部”选项
	    	if(this.getOption().selectAll === true && this.getOption().multiSelect === true){
	    		var _item = this.list.getItem(0);
	    		if(_item && _item[this.getOption().idkey] != "all"){
	    			var cvs = {};
	    			cvs[this.getOption().idkey] = "all";
	    			cvs[this.getOption().capkey] = "("+this.getI18n("qzz.all", "全部")+")";
	    			cvs._filter = false;
	    			this.list.insertItem(0, cvs);
	    		}
	    		this.list._refreshFilter();
	    	}

	    	this._overWidth = false;
	    	var sw = this.getOption().width;
	    	if(this.scrollBar.visible) {
	    		sw -= this.scrollBar.getWidth();
	    	}
	    	if(sWidth > sw) {
	    	    this.listTab.style.width = (sWidth) +  "px";
	    	    this._overWidth = true;
	    	} else {
	    		this.listTab.style.width = "100%";
	    		this._overWidth = false;
	    	}
	    	var hsh = 0;
	    	if(this._overWidth) {
	    	    hsh = this.getHScrollHeight();
	    	}
	    	//计算显示行数
	    	if(!this.autoHeight) {
	    	    this.showCount = parseInt((this._getRectHeight() - hsh)/this._rowHeight, 10);
	    	}
	    	var rlen = this.listTab.rows.length;
	    	var len = this.list.length()
	    	var mxlen = this.showCount < len ? this.showCount : len;
	    	var index = this.topIndex;
	    	var td, row, i, mulIndex;
	    	var _this = this;
	    	this.rowIndex = -1;
	    	var checkBoxWidth = "20px";
	    	var cStr = "";	
	    	var gh = mxlen * this._rowHeight;	    	
	    	//设计宽高	 
	    	if(this.autoHeight) {
	    		if(this._overWidth) {
		    		gh = gh + hsh;
		    	}
	    		this.setHeight(gh);
	    	}
	    	//循环刷新各行，并设置行样式.
	    	for(i = 0; i <= mxlen && index < len; i ++) {
	    		row = this.listTab.rows[i];
	    		if(row == null) {
	    			row = this.listTab.insertRow(i);
	    		}
	    		mulIndex = 0;
	    		var item = this.list.getItem(index);
	    		if(this.getOption().multiSelect) {
	    			if(row.cells.length > 1) {
	    				td = row.cells[mulIndex];
	    			} else {
	    			    //复选框显示
	    				td = row.insertCell(mulIndex);
	    				td.checkBox = new qzz.ui.input.checkbox();//this.createElement("input");
	    				//td.checkBox.type = "checkbox";	  
	    				//this.setStyle(td.checkBox, "checkBox");
	    				td.checkBox._this = this;
	    				td.checkBox.bind("onClick", function(ev) {
	    					//表格筛选框全选择行实现问题，doSelect与onCheckChanged位置对换
	    					_this.doSelect.apply(this, arguments);    					
	    				}, true);
	    				//鼠标事件
	    				td.onmouseover = this.doMouseOverCell;
	    		        td.onmouseout = this.doMouseOutCell;
	    		        
		    			td.appendChild(td.checkBox.getContainer());
		    			td.style.width = checkBoxWidth;
		    			td.style.textAlign = "center";
	    			}	 
	    			td.checkBox.item = item;
	    			
	    			td._this = this;
	    			td.checkBox._selectIndex = index;
	    			td.checkBox.setCheck(item.checked == true);    			
	    			if(item.disabled == true) {
	    				td.checkBox.setDisable(true);
	    				td.checkBox.unbind("onClick");
	    			} else {
	    				td.checkBox.setDisable(false);
	    			}
	    			//样式
		    		if(index == this.selectIndex && !this.selBackgroup) {
		    			if(this.focus) {
		    			    this.setStyle(td, "component_ui_listview_td_over");
		    			} else {
		    				this.setStyle(td, "component_ui_listview_td_nofocus_over");
		    			}
		    		} else {	    		
		    		    this.setStyle(td, "component_ui_listview_td");
		    		}
		    		if(this.getOption().fontSize !== "" && this.getOption().fontSize != null) {
		    			td.style.fontSize = this.getOption().fontSize + "px";
		    		}
		    		if(this._rowHeight != null && this._rowHeight !== "") {
		    			td.style.height = (this._rowHeight - 1) + "px";
		    		}
	    			mulIndex ++;
	    		}
	    		td = row.cells[mulIndex];
	    		if(td == null) {
	    			td = row.insertCell(mulIndex);
	    		}
	    		//把边框去掉
	    		if(this.getOption().multiSelect) {
	    			td.style.paddingLeft = "0px";
	    		}
	    		//样式
	    		if((index == this.selectIndex || item[this.getOption().capkey] == text) && !this.selBackgroup) {
	    			if(this.focus) {
	    			    this.setStyle(td, "component_ui_listview_td_over");
	    			} else {
	    				this.setStyle(td, "component_ui_listview_td_nofocus_over");
	    			}	    			    
	    			this.rowIndex = i;
	    			if(item[this.getOption().capkey] == text) {
	    				this.selectIndex = index;
	    			}
	    		} else {	    		
	    		    this.setStyle(td, "component_ui_listview_td");
	    		}	   
	    		if(this.getOption().fontSize !== "" && this.getOption().fontSize != null) {
	    			td.style.fontSize = this.getOption().fontSize + "px";
	    		}
	    		if(this._rowHeight != null && this._rowHeight !== "") {
	    			td.style.height = (this._rowHeight - 1) + "px";
	    		}
	    		td._this = this;
	    		//选择行号
	    		td._selectIndex = index;
	    		cStr = item[this.getOption().capkey];
	    		index++;
	    		if(this.getOption().viewType=="image") {
	    			if(td._cimg == null) {
	    				td._cimg = this.createElement("img");
	    				td._cimg.style.height = (this._rowHeight - 4) + "px";
	    			}
	    			td._cimg.setAttribute("src", item[this.getOption().idkey]);	
	    			td.setAttribute("title", item.title || cStr);
	    			this._setHtml(td, td._cimg, false);
	    		} else {
	    		    this._setHtml(td, cStr, false);
	    		    td.setAttribute("title", "");
	    		}
	    		//相关事件
	    		if(item.disabled != true) {
	    		    td.onclick = this.doSelect;
	    		    td.ondblclick = this.doItemDBClick;
	    		}
	    		td.onmouseover = this.doMouseOverCell;
	    		td.onmouseout = this.doMouseOutCell;
	    	}
	    	//纵向刷新滚动条.
	    	if(this.showCount < len) {
	    	    this.scrollBar.setScrollCount(len, this.showCount);
	    	    this.setVScrollHide(false);
	    	} else {
	    		this.scrollBar.setScrollCount(0, 0);
	    		this.setVScrollHide(true);
	    	}    	
    	    this.listTabWidth = sWidth;
	    	//横向刷新滚动条
	    	this.refreshScrollBar();   		    
	    	
	    	//清除多余的行
	    	for (var j = rlen - 1; j >= i; j--) {
	    		if(j < this.listTab.rows.length) {
	                this.listTab.deleteRow(j);
	    		}
	        }
	    },
	    refreshScrollBar:function() {
	    	this.base();
	    	this.scrollBar.setScrollIndex(this.topIndex);
	    },
	    /**
	     * 双击事件.
	     */
	    doItemDBClick:function(ev) {
	        var _this = this._this;
	    	var item = _this.list.getItem(this._selectIndex);
	    	if(_this.selectIndex != this._selectIndex || _this.getOption().multiSelect) {
	    	    //刷新选择行.
	            _this.selectIndex = this._selectIndex;
	            this.tmpClassName = "";
	            if(_this.getOption().multiSelect) {
	            	item.checked = !item.checked;
	            	_this.doSelect.apply(this, arguments);
	            }
	            _this.refresh();
	    	}	 
	    	_this.trigger("onDBClick", [item]);
	    	item = null;
	    },
	    /**
	     * 选择事件.
	     * @param ev 事件对象
	     */
	    doSelect : function(ev) {
	    	var _this = this._this;
	    	var item = _this.list.getItem(this._selectIndex);
	    	if(_this.selectIndex != this._selectIndex || _this.getOption().multiSelect) {
	    		//刷新选择行.
	            _this.selectIndex = this._selectIndex;
	            this.tmpClassName = "";
	            if(_this.getOption().multiSelect) {
	            	item.checked = !item.checked;
	            	//全部
	            	if(_this.getOption().selectAll){
	            		var items = _this.list.getItemList();
	            		if(item[_this.getOption().idkey] == "all"){
		            		//全部选中
		            		for(var i=0,j=items.length; i<j; i++){
		            			if(i === 0 || items[i].disabled){continue;}
		            			if(item.checked){
		            				items[i].checked = true;
		            			}else{
		            				items[i].checked = false;
		            			}	            			
		            		}
		            	}else{
		            		var flag = item.checked,fc;
		            		for(var i=0,j=items.length; i<j; i++){
		            			if(i === 0 && items[i][_this.getOption().idkey] === "all" || items[i].disabled){continue;}
		            			if(flag){
		            				if(!items[i].checked){
		            					if(items[0][_this.getOption().idkey] == "all" && items[0].checked){
		    		            			items[0].checked = false;
		    		            			break;
		    		            		}else{
		    		            			fc = true;
		    		            		}
		            				}
		            			}else{
		            				if(items[0][_this.getOption().idkey] == "all" && items[0].checked){
	    		            			items[0].checked = false;
	    		            			break;
	    		            		}
		            			}	            			
		            		}
		            		if(flag && !fc && items[0][_this.getOption().idkey] == "all" && !items[0].checked){
		            			items[0].checked = true;
		            		}
		            	}
	            	}
	            }
	            _this.refresh();
	    	}	    	
	    	if(typeof _this.onSelect == "function") {
	    		//调用事件.	    		
	    		if(item != null) {
	    		    _this.onSelect(_this.selectIndex, item);
	    		}
	    	}
	    	_this.trigger("onSelect", [_this.selectIndex, item]);
	    	if(_this.getOption().multiSelect) {
	    		if(typeof _this.onCheckChanged === "function") {
					try {
					    _this.onCheckChanged(item, item.checked);
					} catch(e) {
						_this.logInfo("[onCheckChanged] error:" + e.message + e.stack);
					}
				}
	    	}
	    	item = null;
	    },
	    /**
	     * 通过Text设置为选择.
	     * @name setSelectByText
	     * @param {string|Array} text 字符串
	     */
	    setSelectByText:function(Text) {
	    	this.selBackgroup = false;
	    	if(this.getOption().multiSelect) {
	    		if(typeof Text === "string") {
	    			Text = Text.split(/[ ,，]+/g);
	    		}	    		
	    		var clen = Text.length;
	    		var ci = 0;
	    		var items = [];
	    		for(var i = 0, len = this.list.length(true); i < len && ci < clen; i++) {
	    			var item = this.list.getItem(i, true);
	    			item.checked = false;
	    			for(var j = 0; j < clen; j++) {
	    				if(item[this.getOption().capkey] == Text[j]) {
	    					item.checked = true;
	    					ci++;
	    					break;
	    				}
	    			}
	    			if(item.checked) {
	    				items.push(item);
	    			}
	    		}
	    		this.refresh();
	    		return items;
	    	} else {
	    	    this.selectIndex = this.list.indexOfText(Text, true);
	    	    this.refresh();
	    	    return this.selectIndex;
	    	}
	    	
	    },
	    /**
	     * 通过值设置为选择.
	     * @name setSelect
	     * @param {string|Array} value 值
	     */
	    setSelect:function(value) {
	    	this.selBackgroup = false;
	    	if(this.getOption().multiSelect) {	    		
	    		if(typeof value === "string") {
	    			value = value.split(/[ ,，]+/g);
	    		} else if(typeof value === "number"){
	    			value = [value + ""];
	    		}
	    		//全部
	    		if(this.getOption().selectAll && value && value[0] === "all"){
	    			var items = this.list.getItemList();
	    			value = [];
	    			for(var i=0,j=items.length; i<j; i++){
	    				if(items[i].checked){
	    					value.push(items[i][this.getOption().idkey]);
	    				}
	    			}
	    		}
	    		for(var i = 0, len = this.list.length(true); i < len; i++) {
	    			var item = this.list.getItem(i, true);	    			
	    			item.checked = false;
	    			for(var j = 0, clen = value.length; j < clen; j++) {
	    				if(item[this.getOption().idkey] != null && item[this.getOption().idkey] === value[j] 
	    				    || item[this.getOption().capkey] === value[j]) {
	    					item.checked = true;
	    					break;
	    				}
	    			}
	    		}
	    	} else {
	    	    this.selectIndex = this.list.indexOf(value, true);
	    	}
	    	this.refresh();
	    },
	    /**
	     * 获取选择的所有节点.
	     */
	    getSelect:function() {
	    	if(this.getOption().multiSelect) {
	    		var items = [];
	    		for(var i = 0; i < this.list.length(true); i++) {
	    			var item = this.list.getItem(i, true);
	    			if(item.checked) {
	    			    items.push(item);
	    			}
	    			item = null;
	    		}
	    		return items;
	    	} else {
	    		return this.list.getItem(_this.selectIndex);
	    	}
	    },
	    /**
	     * 鼠标移入.
	     * @param ev 事件对象
	     */
	    doMouseOverCell : function(ev) {
	    	var _this = this._this;
	    	this.tmpClassName = this.className;
	    	if(_this.focus) {
	            _this.setStyle(this, "component_ui_listview_td_over");
	            var otherCell = this.parentNode.cells[1 - this.cellIndex];
	            if(_this.isNotEmpty(otherCell)) {
	            	otherCell.tmpClassName = otherCell.className;
		            _this.setStyle(otherCell, "component_ui_listview_td_over");	   
		            otherCell = null;
	            }
	            if(_this.getOption().multiSelect) {
	            	var checkCell = this.parentNode.cells[0];
	            	checkCell.style.width = "20px";
	            	checkCell.style.textAlign = "center";
	            }
	            if(!_this.selBackgroup && _this.selectIndex != this._selectIndex) {
					_this.selectIndex = this._selectIndex;
	            	_this.refresh();
	            	_this.selBackgroup = true;
	            }
	    	}
	    },
	    /**
	     * 鼠标移出.
	     * @param ev 事件对象
	     */
	    doMouseOutCell : function(ev) {
	    	var _this = this._this;
	    	if(_this.focus) {
		    	if(this.tmpClassName !== "") {
		            _this.setStyle(this, this.tmpClassName, undefined, false);
		            var otherCell = this.parentNode.cells[1 - this.cellIndex];
		            if(_this.isNotEmpty(otherCell)) {
			            _this.setStyle(otherCell, otherCell.tmpClassName);
			            otherCell = null;
		            }
		            if(_this.getOption().multiSelect) {
		            	var checkCell = this.parentNode.cells[0];
		            	checkCell.style.width = "20px";
		            	checkCell.style.textAlign = "center";
		            }
		    	}
	    	}
	    },
	    /**
	     * 鼠标滚动.
	     * @param ev 事件对象
	     */
	    doMouseWheel:function(ev) {
	    	this.base();
	        var ent = ev;
	        var scint = 0;
	        if (ent.wheelDelta) {
	            scint = ent.wheelDelta;
	        } else {
	            scint = ent.detail * (-1);
	        }
	        var _this = this;
	        //处理滚动
	        if (scint > 0) {
	        	_this.scrollBar.scrollPrior();
	        } else {
	        	_this.scrollBar.scrollNext();
	        }
	        _this = null;
	        ent.returnValue = false;
	        ent = null;
	        scint = null;
	        return false;
	    },
	    /**
	     * 键盘按下.
	     * @param ev 事件对象
	     */
	    doKeyDown:function(ev, key){
	    	var ent = ev;
	    	//方向控制
	    	if (key == this.keyBoard.UP) {
	    		this.prior();
	        } else if (key == this.keyBoard.DOWN) {
	        	this.next();
	        }
	    	if((key == this.keyBoard.UP || key == this.keyBoard.DOWN) && typeof this.onSelect == "function") {
	    		//调用事件.	
	    		var item = this.list.getItem(this.selectIndex);	
	    		if(item != null && this._scrollFireEvent) {
	    		    this.onSelect(this.selectIndex, item);
	    		}
	    	}
	    	ent = null;
	    	key = null;
	    },
	    /**
	     * 键盘弹起.
	     * @param ev 事件对象
	     */
	    doKeyUp:function(ev, key){
	    	if(key == this.keyBoard.ENTER && typeof this.onSelect == "function") {	
	    		//回车处理
				var item = this.list.getItem(this.selectIndex);				
				if(item != null) {
					if(this.getOption().multiSelect) {
						item.checked = !item.checked;
						this.refresh();
					}
				    this.onSelect(this.selectIndex, item);
				}				
				item = null;
				this.logInfo("key up");
			}  
	    },
	    /**
	     * 显示条数.
	     * @param count 数量
	     */
	    setShowCount:function(count) {
	    	if(this.showCount != count) {
	    	    this.showCount = count;
	    	    this.getOption().height = count * this._rowHeight;
	    	    this.refresh();
	    	}
	    },
	    /**
	     * 初始化数列.
	     * @param {Array} datas 数据对象.
	     */
	    setItemList:function(datas) {
	    	this.list.filtered = false;
	    	this.list.filter = "";
	    	this.list.setItemList(datas);
	    	this.topIndex = 0;
	    	this.refresh();
	    },
	    value:function(datas) {
	    	if(datas == null) {
	    		
	    	} else {
	    		this.setItemList(datas);
	    	}
	    },
	    /**
	     * 添加节点.
	     * @param {object} item 节点对象
	     */
	    addItem:function(item) {
	    	this.list.addItem(item);
	    	this.refresh();
	    },
	    /**
	     * 删除节点.
	     * @name delItem
	     * @param {index} index 序号
	     */
	    delItem:function(index, done) {
	    	this.list.delItem(index);
	    	if(done != false) {
	    	    this.refresh();
	    	}
	    },
	    /**
	     * 设置过滤.
	     * @name addFilter
	     * @param {string} text 字符串
	     */
	    addFilter:function(text, done) {
	    	this.list.addFilter(text, done);
	    	this.topIndex = 0;
	    	if(this.list.length() ==  1) {
		    	this.selectIndex = 0;
		    } else {
		    	this.selectIndex = -1;
		    }
	    	if(this.getOption().selectAll) {
		    	var isall = true;
		        for(var i = 0; isall && i < this.list.length(); i++) {
		            var citem = this.list.getItem(i);
		            if(citem[this.getOption().idkey] !== "all") {
		            	isall = isall && citem.checked === true;
		            }
		        }
	        	var citem = this.list.getItem(0);
	        	if(citem != null && citem[this.getOption().idkey] === "all") {
	        	    citem.checked = isall;
	        	}
	        }	        
	    	if(done != false) {
	    	    this.refresh(text);
	    	}
	    },
	    /**
	     * 执行过滤
	     * @name doFilter
	     */
	    doFilter:function() {
	    	this.list.doFilter();
	    	this.refresh();
	    },
	    /**
	     * 清除过滤.
	     * @name clearFilter
	     * @param {string} text 过滤条件
	     */
	    clearFilter:function(text) {
	    	this.list.clearFilter();
	    },
	    /**
	     * 过滤条件是否存在
	     * @name filterExist
	     * @param {string} text 过滤条件.
	     * @return 返回结果
	     */
	    filterExist:function(text) {
	    	return this.list.filterExist(text)
	    },
	    /**
	     * 返回过滤条件.
	     * @name getFilter
	     * @return {string} 过滤字符串.
	     */
	    getFilter:function() {
	    	return this.list.filter;
	    },
	    /**
	     * 上一个节点.
	     */
	    prior:function() {
	    	if(this.selectIndex > 0) {
    		    this.selectIndex --;
    		    if(this.selectIndex < this.topIndex) {
    		    	this.topIndex = this.selectIndex;
    		    } else if(this.selectIndex > this.topIndex + this.showCount - 1) {
    		    	this.topIndex = this.selectIndex - this.showCount + 1;
    		    }
    		    this.scrollBar.setScrollIndex(this.topIndex);
	    		this.refresh();
    		} else {
    			this.selectIndex = 0;
    			this.refresh();
    		}
	    },
	    /**
	     * 下一个节点.
	     */
	    next:function() {
	    	if(this.selectIndex < this.list.length() - 1) {
	        	this.selectIndex ++;
	        	if(this.selectIndex < this.topIndex) {
    		    	this.topIndex = this.selectIndex;
    		    } else if(this.selectIndex > this.topIndex + this.showCount - 1) {
    		    	this.topIndex = this.selectIndex - this.showCount + 1;
    		    }
	        	this.scrollBar.setScrollIndex(this.topIndex);
	        	this.refresh();
        	} else {
        		this.selectIndex = this.list.length() - 1;
        		this.refresh();
        	}
	    },
	    /**
	     * 获取当前节点.
	     * @return 返回节点.
	     */
	    getCurItem:function() {
	    	return this.list.getItem(this.selectIndex);
	    },
	    /**
	     * 获取节点
	     * @param index 序号
	     * @return 返回节点.
	     */
	    getItem:function(index) {
	    	return this.list.getItem(index);
	    },
	    /**
	     * 查找字符串是否存在节点.
	     * @param text 字符串
	     */
	    indexOfText:function(text, filter) {
	    	return this.list.indexOfText(text, filter);
	    },
	    /**
	     * 查找值 是否存在节点. 
	     * @param value 值
	     */
	    indexOf:function(value, filter) {
	    	return this.list.indexOf(value, filter);
	    },
	    /**
	     * 获取选择节点序号.
	     * @return 返回序号
	     */
	    getSelectIndex:function() {	    	
	    	if(this.list.filtered) {
	    		var item = this.list.getItem(this.selectIndex);
	    		var re = -1;
	    		if(item != null) {
	    			re = this.list.indexOfText(item[this.getOption().capkey], true);
	    		}
	    		item = null;
	    		return re;
	    	} else {
	    	    return this.selectIndex;
	    	}
	    },
	    /**
	     * 结束刷新.
	     */
	    endUpdate:function() {
	    	this._update = true;
	    	this.refresh();
	    },
	    /**
	     * 执行滚动.
	     * @param scrollIndex 序号
	     * @param scrollCount 数量
	     */
	    doScroll:function(scrollIndex, scrollCount) {
	    	this.topIndex = scrollIndex;
    	    this.refresh();
	    },
	    /**
	     * 执行大小变更
	     */
	    _doResize:function(el) {
	    	this.base(el);
	    },	
	    /**
	     * 执行失去焦点事件.
	     */
	    doBlur:function() {
	    	this.base();
	    	this.refresh();
	    },
	    /**
	     * 执行获得焦点事件.
	     */
	    doFocus:function() {
	    	this.base();
	    	this.refresh();
	    },
	    /**
	     * 全部选择.
	     */
	    doSelectAll:function() {
	    	if(this.getOption().multiSelect) {
	    		for(var i = 0; i < this.list.length(true); i++) {
	    			this.list.getItem(i, true).checked = true;
	    		}	
	    		this.refresh();
	    	}
	    },
	    /**
	     * 全部取消.
	     */
	    clearSelectAll:function() {
	    	if(this.getOption().multiSelect) {
	    		for(var i = 0; i < this.list.length(true); i++) {
	    			this.list.getItem(i, true).checked = false;
	    		}
	    		this.refresh();
	    	}
	    },
	    /**
	     * 长度.
	     */
	    length:function(all) {
	    	return this.list.length(all)
	    },
	    getHScrollHide:function() {
	    	var sw = this.getOption().width;
	    	if(this.scrollBar.visible) {
	    		sw -= this.scrollBar.getWidth();
	    	}
	    	return this.listTabWidth <= sw;
	    },
	    setIdkey:function(key) {
        	this.getOption().idkey = key;
        }
	});
	/**
	 * 列表控件.
	 */
	_bindRenderFunc("qzzlistview", qzz.ui.listview);
	return qzz.ui.listview;
});
	